package com.myproject.controller;

import java.security.Principal;

import javax.servlet.http.HttpServletRequest;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MainController {

	@RequestMapping("/")
	@ResponseBody
	public String index(){
		return "hello world";
	}
	
	@RequestMapping("/test")
	@ResponseBody
	public String test(){
		return "test";
	}
	
	@RequestMapping("/login")
	public String login(){
		return "login";
	}
	
	@RequestMapping("/profile")
	@ResponseBody
	public Principal profile(Principal principal){
		System.out.println(SecurityContextHolder.getContext().getAuthentication().getName());
		return principal;
	}
	
	@RequestMapping("/user")
	public String user(HttpServletRequest request){
		return "user";
	}
}
